Skip to content

Security: Fix SSRF vulnerability in attach_photo_from_url#56

Open
bellisabell wants to merge 1 commit intomainfrom
bell/fix-ssrf-uri-open
Open

Security: Fix SSRF vulnerability in attach_photo_from_url#56
bellisabell wants to merge 1 commit intomainfrom
bell/fix-ssrf-uri-open

Conversation

@bellisabell
Copy link
Copy Markdown
Contributor

Summary

Fixes a critical SSRF vulnerability in attach_photo_from_url and attach_cover_from_url methods where URI.open(url) was used without any validation.

Changes

  • URL scheme validation: Only allow http:// and https:// URLs (blocks file://, ftp://, etc.)
  • Timeout constraints: 10-second open/read timeouts using Net::HTTP instead of URI.open
  • Content-type validation: Only allow image types (image/jpeg, image/png, image/gif, image/webp)
  • File size validation: Maximum 10MB attachment size
  • Safe redirect handling: Follow up to 3 redirects, validating scheme on each

Security Impact

Previously an attacker could:

  • Access internal services via http://localhost:... or http://169.254.169.254/... (cloud metadata)
  • Read local files via file:///etc/passwd
  • Cause DoS via slow/infinite responses or huge files

Now all these vectors are blocked.

Closes #16

…ver_from_url

- Validate URL scheme (whitelist http/https only)
- Add timeout constraints (10 second open/read timeout)
- Validate content-type (only allow image types)
- Validate file size (max 10MB)
- Handle redirects safely (up to 3, with scheme validation)
- Replace URI.open with Net::HTTP for better control

Closes #16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: SSRF vulnerability via URI.open in attach_photo_from_url / attach_cover_from_url

2 participants